package sdau.hjk.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sdau.hjk.dao.IManagerNoticeDao;
import sdau.hjk.entity.ManagerNotice;
import sdau.hjk.service.IManagerNoticeService;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 *@version 1.0
 *@author: huangjiakai
 *@create:2021−03-29 16:05
 *@className:sdau.hjk.service.Impl.ManagerNoticeService
 *@description: TODO
 */
@Service("managerNoticeService")
public class ManagerNoticeService implements IManagerNoticeService {
    @Autowired
    private IManagerNoticeDao noticeDao;

    @Override
    public List<ManagerNotice> findAll() {
        return noticeDao.findAll();
    }

    @Override
    public ManagerNotice findById(Integer id) {
        return noticeDao.findById(id);
    }

    @Override
    public void saveManagerNotice(ManagerNotice managerNotice) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        Date date =calendar.getTime();
        String dateStringParse = sdf.format(date);
        Date dateParse = sdf.parse(dateStringParse);
        managerNotice.setDate(dateParse);
        noticeDao.save(managerNotice);
    }
}
